
import { EggAppConfig, EggAppInfo, PowerPartial } from "egg";

export default (appInfo: EggAppInfo) => {
  const config = {} as PowerPartial<EggAppConfig>;

  // override config from framework / plugin
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + "_1724578573972_4851";

  // add your egg config in here
  // 配置中间件
  config.middleware = ['customError'];
  config.security = {
    csrf: {
      enable: false,
    },
  };
  config.view = {
    defaultViewEngine: "nunjucks",
  };
  config.bcrypt = {
    saltRounds: 10,
  };
  config.jwt = {
    secret: "lego123123",
  }
  config.redis = {
    client: {
      port: 6379,
      host: "127.0.0.1",
      password: "",
      db: 0,
    }
  }
  config.cors = {
    origin: "*",
    allowMethods: "GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS",
  }
  const giteeOauthConfig = {
    cid:'5bb09e068a7cd69b17b9452be4fe376ba5b46a6326f9f908757645516c986502',
    secret: 'f46088613105d9ace2f1fc2ef5d3f8434b4db5dcf38e45c6d1707248022d5916',
    redirect_uri: 'http://localhost:7001/api/user/gitee/callback',
    authUrl:'https://gitee.com/oauth/token'
  }
  // add your special config in here
  //中间件配置写在这里
  const bizConfig = {
    sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`,
    log: {
      methods: ["POST"],
    },
    mongoose: {
      //设置mongoose的连接地址
      url: "mongodb://localhost:27017/lego",
    },
    giteeOauthConfig
  };

  // the return config will combines to EggAppConfig
  return {
    ...config,
    ...bizConfig,
  };
};
